package com.tjsinfo.tjsoa.fileExpress.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.tjsinfo.tjsoa.fileExpress.vo.FileExpressGroup;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;

/**
 * A data access object (DAO) providing persistence and search support for
 * FileExpressGroup entities. Transaction control of the save(), update() and
 * delete() operations can directly support Spring container-managed
 * transactions or they can be augmented to handle user-managed Spring
 * transactions. Each of these methods provides additional information for how
 * to configure it for the desired type of transaction control.
 * 
 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup
 * @author MyEclipse Persistence Tools
 */

public class FileExpressGroupDAO extends HibernateDaoSupport implements IFileExpressGroupDAO{
	private static final Log log = LogFactory.getLog(FileExpressGroupDAO.class);
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#save(com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup)
	 */
	public void save(FileExpressGroup transientInstance) {
		log.debug("saving FileExpressGroup instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void update(FileExpressGroup transientInstance) {
		log.debug("saving FileExpressGroup instance");
		try {
			getHibernateTemplate().update(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#delete(com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup)
	 */
	public void delete(FileExpressGroup persistentInstance) {
		log.debug("deleting FileExpressGroup instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#findById(java.lang.Integer)
	 */
	public FileExpressGroup findById(java.lang.String id) {
		log.debug("getting FileExpressGroup instance with id: " + id);
		try {
			FileExpressGroup instance = (FileExpressGroup) getHibernateTemplate()
					.get(
							"com.tjsinfo.tjsoa.fileExpress.vo.FileExpressGroup",
							id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#findByExample(com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup)
	 */
	public List findByExample(FileExpressGroup instance) {
		log.debug("finding FileExpressGroup instance by example");
		try {
			List results = getHibernateTemplate().findByExample(instance); 
			log.debug("find by example successful, result size: "
					+ results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#findByProperty(java.lang.String, java.lang.Object)
	 */
	public List findByProperty(String propertyName, Object value) {
		log.debug("finding FileExpressGroup instance with property: "
				+ propertyName + ", value: " + value);
		try {
			String queryString = "from FileExpressGroup as model where model."
					+ propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#findByGroupName(java.lang.Object)
	 */
	public List findByGroupName(Object groupName) {
		return findByProperty(GROUP_NAME, groupName);
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#findAll()
	 */
	public List findAll() {
		log.debug("finding all FileExpressGroup instances");
		try {
			String queryString = "from FileExpressGroup";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#merge(com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup)
	 */
	public FileExpressGroup merge(FileExpressGroup detachedInstance) {
		log.debug("merging FileExpressGroup instance");
		try {
			FileExpressGroup result = (FileExpressGroup) getHibernateTemplate().merge(
					detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#attachDirty(com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup)
	 */
	public void attachDirty(FileExpressGroup instance) {
		log.debug("attaching dirty FileExpressGroup instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	/* (non-Javadoc)
	 * @see com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.IFileExpressGroupDAO#attachClean(com.tjsinfo.tjsoa.fileExpress.FileExpress_Group.FileExpressGroup)
	 */
	public void attachClean(FileExpressGroup instance) {
		log.debug("attaching clean FileExpressGroup instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

}